import { moduleTypeRule, objectAny } from "../../options/base";
import { homeMenuToPage } from "../../utils/tabCommon";
import { goToPage, orderNavToRightPage, toggleOrderStatus, togglePackStatus } from "../../utils/utils";

export default {
    props: {
        dataList: Array,
        default() {
            return []
        }
    },
    setup() {

        console.log(6666)    
        
        // 跑腿模块下的 包裹类型转换显示 
        // 例如 中物件 小物件
        const togglePackText=(list:Array<number>,childList:Array<objectAny>)=>{
            const fastList=childList.filter(it=>it.fast_status)
            const toggleList= list.map(it=>togglePackStatus(it))
            if(fastList.length>0){
                const strJson=togglePackStatus(4);
                strJson.text=`${strJson.text} * ${fastList.length}`
                toggleList.push(strJson)
            }
            return toggleList;
        }

        // 跳转到新的页面
        const navToPage=(it:objectAny,moduleName:moduleTypeRule)=>{
            orderNavToRightPage(it,moduleName);
        }
        // 查看订单详细
        const viewOrderDetail=(it:objectAny)=>{
            goToPage({
                path:`/generalUser/orderDetails/orderDetails`,
                navType:`push`,
                params:{
                    id:it.order_id,
                    module:it.moduleName
                }
            })
        }
        // 马上去支付
        const goToPay=(it:objectAny)=>{
            goToPage({
                path:`/common/orderCounter/orderCounter`,
                navType:`push`,
                params:{
                    order_id:it.order_id,
                    module:it.moduleName
                }
            })
        }

        return {
            goToPay,
            navToPage,
            togglePackText,
            toggleOrderStatus,
            homeMenuToPage,
            viewOrderDetail
        }
    }

}